<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script src="../js/axios.js"></script>
		<script>
			/* 需求1: 查询id=1的用户
						   
			GET方式1: 动态拼接参数的写法 
			url: http://localhost:8090/axios/getUserById?id=1
			*/
			let url1 = "http://localhost:8090/axios/getUserById?id=1"
			axios.get(url1).then(promise => {
				console.log(promise.data)
			})
			/* 
							GET方式2: 利用restFul查询数据
							需求:     查询sex=女 age>18
							
							原因: restFul结构越来越受欢迎,则拼接restFul结构 变得繁琐.
							模板字符串:  
								语法: 一对反引号  ``
								取值: ${key} 形式取值
								优势: 保留代码的格式
								
			*/
			let sex2 = "女"
			let age2 = 18
			//let url2 = "http://localhost:8090/axios/user/"+sex2+"/"+age2
			let url2 = `http://localhost:8090/axios/user/${sex2}/${age2}`
			axios.get(url2).then(promise => {
				console.log(promise.data)
			})
		</script>
	</body>
</html>
